* Balance on Teachers


		forvalue j=1/2 {
			if `j' == 1 {
				local mylist nothreat_cycle1_true nothreat_cycle2 ntc2_postbreak nothreat_cycle3 nothreat_p2 nothreat_m2 nothreat_m1
			}
			else if `j' == 2 {
				local mylist postconf_p1 postconf_p2 postconf_m1 postconf_m2 diff_m1 diff_m2 diff_p1 diff_p2 diff_p3
			}
			
			
			foreach var of varlist `mylist' {
				preserve
				tab subject, gen(__tmp_subject)
				
					* Create exp_capped categories
					
					duplicates drop year id, force
					
					sort id year
					
					
					label var exp_capped "Teacher Experience"
					label var exp_capped_squared "Teacher Experience Squared"
					label var experience "Teacher Experience"
					label var experience_squared "Teacher Experience Squared"
					label var tblack "Black"
					label var thisp "Hispanic"
					label var tasian "Asian"
					label var tlf_L "Lagged Evaluation Score"
					label var he_lastyear "Highly Effective (t-1)"
					label var me_lastyear "Minimally Effective (t-1)"
					
					if "`var'" == "nothreat_m1"{
						drop if year == 2010
					}
					
					if "`var'" == "diff_m2" {
						*drop if nothreat_m2 == 0
					}
					
					estimates clear
					local i = 1
				
					reghdfe `var' $experiencevar $subjectvar, absorb(sch_id year) vce(robust)
					test $experiencevar
					estadd scalar F_diff = r(F)
					estadd scalar p_diff = r(p)
					estimates store model_`i'
					local i = `i' + 1
				
					reghdfe `var' $experiencevar $tdemovars $subjectvar, absorb(sch_id year) vce(robust)
					test $experiencevar $tdemovars
					estadd scalar F_diff = r(F)
					estadd scalar p_diff = r(p)
					estimates store model_`i'
					local i = `i' + 1
					
					reghdfe `var' $experiencevar $prevvars $tdemovars $subjectvar, absorb(sch_id year) vce(robust)
					test $experiencevar $prevvars $tdemovars
					estadd scalar F_diff = r(F)
					estadd scalar p_diff = r(p)
					estimates store model_`i'
					local i = `i' + 1
										
					reghdfe `var' $experiencevar $prevvars $prevvars_2 $tdemovars $subjectvar, absorb(sch_id year) vce(robust)
					test $experiencevar $prevvars $tdemovars  $prevvars_2
					estadd scalar F_diff = r(F)
					estadd scalar p_diff = r(p)
					estimates store model_`i'
					local i = `i' + 1
					
								
				estfe model*, labels(sch_id "School FE" year "Year FE" grade "Grade FE" id "Teacher FE")
					
				esttab model* using "$output_dir\Tables\_Table_15_`var'.tex", replace indicate(`r(indicate_fe)', labels("X" " ")) ///
					keep($experiencevar $tdemovars $prevvars $prevvars_2 ) nobaselevels star(+ 0.10 * 0.05 ** 0.01 *** 0.001) noomitted nomtitle scalars("F_diff F" "p_diff p") se label ///
					nonotes substitute(/ "")
				* return stored estimates to their previous state
				estfe model*, restore
			
				restore
			
				}
			}
		
		
		* now do the combined table
		preserve
			tab subject, gen(__tmp_subject)
				
				* Create exp_capped categories
				
				duplicates drop year id, force
				
				sort id year
				
				
				label var exp_capped "Teacher Experience"
				label var exp_capped_squared "Teacher Experience Squared"
				label var experience "Teacher Experience"
				label var experience_squared "Teacher Experience Squared"
				label var tblack "Black"
				label var thisp "Hispanic"
				label var tasian "Asian"
				label var tlf_L "Lagged Evaluation Score"
				label var he_lastyear "Highly Effective (t-1)"
				label var me_lastyear "Minimally Effective (t-1)"
									
				estimates clear
				local i = 1
												
				reghdfe nothreat_p2 $experiencevar $prevvars $prevvars_2 $tdemovars $subjectvar, absorb(sch_id year) vce(robust)
				test $experiencevar $prevvars $tdemovars  $prevvars_2
				estadd scalar F_diff = r(F)
				estadd scalar p_diff = r(p)
				estimates store model_`i'
				local i = `i' + 1
				
				reghdfe nothreat_m2 $experiencevar $prevvars $prevvars_2 $tdemovars $subjectvar, absorb(sch_id year) vce(robust)
				test $experiencevar $prevvars $tdemovars  $prevvars_2
				estadd scalar F_diff = r(F)
				estadd scalar p_diff = r(p)
				estimates store model_`i'
				local i = `i' + 1
				
				reghdfe nothreat_cycle3 $experiencevar $prevvars $prevvars_2 $tdemovars $subjectvar, absorb(sch_id year) vce(robust)
				test $experiencevar $prevvars $tdemovars  $prevvars_2
				estadd scalar F_diff = r(F)
				estadd scalar p_diff = r(p)
				estimates store model_`i'
				local i = `i' + 1
				
										
			estfe model*, labels(sch_id "School FE" year "Year FE" grade "Grade FE" id "Teacher FE")
				
			esttab model* using "$output_dir\Tables\_Table_15_combined_p2m2nothreat3.tex", replace indicate(`r(indicate_fe)', labels("X" " ")) ///
				keep($experiencevar $tdemovars $prevvars $prevvars_2 ) nobaselevels star(+ 0.10 * 0.05 ** 0.01 *** 0.001) noomitted nonumbers scalars("F_diff F" "p_diff p") se label ///
				mtitles("Admin" "External" "Unmonitored Time") nonotes substitute(/ "")
			* return stored estimates to their previous state
			estfe model*, restore
			
		restore
	
